package com.f6.weixin.utils;

import com.f6.weixin.common.vo.WeixinPayRequestVO;

public class WeixinPayRequestDataBuilder {
	 public String appid;
	    public String mch_id;
	    public String device_info;
	    public String body;
	    public String detail;
	    public String attach;
	    public String out_trade_no;
	    public String fee_type;
	    public int total_fee;
	    public String spbill_create_ip;
	    public String time_start;
	    public String time_expire;
	    public String goods_tag;
	    public String notify_url;
	    public String trade_type;
	    public String product_id;
	    public String limit_pay;
	    public String openid;
	    public WeixinPayRequestDataBuilder(String appid, String mch_id, String body, String out_trade_no, Integer total_fee,
	                      String spbill_create_ip, String notify_url, String trade_type) {
	      if (appid == null) {
	        throw new IllegalArgumentException("传入参数appid不能为null");
	      }
	      if (mch_id == null) {
	        throw new IllegalArgumentException("传入参数mch_id不能为null");
	      }
	      if (body == null) {
	        throw new IllegalArgumentException("传入参数body不能为null");
	      }
	      if (out_trade_no == null) {
	        throw new IllegalArgumentException("传入参数out_trade_no不能为null");
	      }
	      if (total_fee == null) {
	        throw new IllegalArgumentException("传入参数total_fee不能为null");
	      }
	      if (spbill_create_ip == null) {
	        throw new IllegalArgumentException("传入参数spbill_create_ip不能为null");
	      }
	      if (notify_url == null) {
	        throw new IllegalArgumentException("传入参数notify_url不能为null");
	      }
	      if (trade_type == null) {
	        throw new IllegalArgumentException("传入参数trade_type不能为null");
	      }
	      this.appid = appid;
	      this.mch_id = mch_id;
	      this.body = body;
	      this.out_trade_no = out_trade_no;
	      this.total_fee = total_fee;
	      this.spbill_create_ip = spbill_create_ip;
	      this.notify_url = notify_url;
	      this.trade_type = trade_type;
	    }
	    public WeixinPayRequestDataBuilder setDevice_info(String device_info) {
	      this.device_info = device_info;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setDetail(String detail) {
	      this.detail = detail;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setAttach(String attach) {
	      this.attach = attach;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setFee_type(String fee_type) {
	      this.fee_type = fee_type;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setTime_start(String time_start) {
	      this.time_start = time_start;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setTime_expire(String time_expire) {
	      this.time_expire = time_expire;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setGoods_tag(String goods_tag) {
	      this.goods_tag = goods_tag;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setProduct_id(String product_id) {
	      this.product_id = product_id;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setLimit_pay(String limit_pay) {
	      this.limit_pay = limit_pay;
	      return this;
	    }
	    public WeixinPayRequestDataBuilder setOpenid(String openid) {
	      this.openid = openid;
	      return this;
	    }
	    public WeixinPayRequestVO build() {
	      if("JSAPI".equals(this.trade_type) && this.openid == null) {
	        throw new IllegalArgumentException("当传入trade_type为JSAPI时，openid为必填参数");
	      }
	      if("NATIVE".equals(this.trade_type) && this.product_id == null) {
	        throw new IllegalArgumentException("当传入trade_type为NATIVE时，product_id为必填参数");
	      }
	      return new WeixinPayRequestVO(this);
	    }
	  }
 
